#!/usr/bin/env bash

set -Eeuxo pipefail
source ./tasks/helpers.sh
set +x

export LUA_PATH="$TEST_VENDOR_LUA_SHARE_DIR/?.lua;$TEST_VENDOR_LUA_SHARE_DIR/?/init.lua;;"
export LUA_CPATH="$TEST_VENDOR_LUA_LIB_DIR/?.so;;"

mapfile -t lua_files < <(git ls-files | grep '\.lua$')
mapfile -t shebang_files < <(git grep -El "^#!/.*(resty|lua)" || true)
files=(
  "${lua_files[@]}"
  "${shebang_files[@]}"
)
set -x
"$TEST_VENDOR_LUA_DIR/bin/luacheck" "${files[@]}"
